package top.csjss.hospital.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.csjss.hospital.entity.Department;
import top.csjss.hospital.mapper.DepartmentMapper;
import top.csjss.hospital.service.DepartmentService;
import top.csjss.hospital.vo.DepartmentVO;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author ztf
 * @Date 19:14 2021/10/20
 **/
@Service
public class DepartmentServiceImpl implements DepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public List<DepartmentVO> selectDepartment() {
        //查询
        List<Department> departments = departmentMapper.selectByExample(null);
        //封装数据
        List<DepartmentVO> data = new ArrayList<>();
        for (Department department : departments) {
            DepartmentVO vo = new DepartmentVO(department.getDepartmentId(),department.getDepartment());
            data.add(vo);
        }
        return data;
    }
}
